Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[problem] Round czy stringformat [[[ ograniczenie liczby po przecinku]]]


Rekomendowane odpowiedzi

Opublikowano

Chce zrobić procentowy zapis aktualnie pobieranego pliku ,tylko żeby był taki np. 7,6 % [zaokrąglanie[ a nie 7.6657547457647 jak to w skrypcie.

 





#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("serverinfo updater", 240, 61, 192, 124)
$Button1 = GUICtrlCreateButton("Zaktualizuj listę serwerów", 8, 0, 153, 41)
$Progress1 = GUICtrlCreateProgress(8, 40, 201, 17)
GUICtrlSetState(-1,$GUI_HIDE)
$SURPRISE = GUICtrlCreateLabel("Line 2 Cell 1", 130, 50) ; next line
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
 case $Button1
; Advanced example - downloading in the background
Local $hDownload = InetGet("[url="http://download.mozilla.org/?product=firefox-12.0&os=win?=pl"]http://download.mozilla.org/?product=firefox-12.0&os=win?=pl[/url]", @TempDir & "\update.dat", 1, 1)
$size = InetGetSize("[url="http://download.mozilla.org/?product=firefox-12.0&os=win?=pl"]http://download.mozilla.org/?product=firefox-12.0&os=win?=pl[/url]")
GUICtrlSetState($Progress1,$GUI_SHOW)
Do
$info = InetGetInfo($hDownload,0)
$observer = GUICtrlSetData($Progress1,$info/$size*100)
$observer = GUICtrlSetData($SURPRISE ,$info/$size*100)
 Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.
exit

EndSwitch
WEnd

Opublikowano
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("serverinfo updater", 240, 61, 192, 124)
$Button1 = GUICtrlCreateButton("Zaktualizuj listę serwerów", 8, 0, 153, 41)
$Progress1 = GUICtrlCreateProgress(8, 40, 201, 17)
GUICtrlSetState(-1,$GUI_HIDE)
$SURPRISE = GUICtrlCreateLabel("Line 2 Cell 1", 130, 50) ; next line
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
  Exit
 case $Button1
; Advanced example - downloading in the background
Local $hDownload = InetGet("[url="http://download.mozilla.org/?product=firefox-12.0&os=win?=pl"]http://download.mozi...&os=win?=pl[/url]", @TempDir & "\update.dat", 1, 1)
$size = InetGetSize("[url="http://download.mozilla.org/?product=firefox-12.0&os=win?=pl"]http://download.mozi...&os=win?=pl[/url]")
GUICtrlSetState($Progress1,$GUI_SHOW)
Do
$info = InetGetInfo($hDownload,0)
$observer = GUICtrlSetData($Progress1,round($info/$size*100, 1))
$observer = GUICtrlSetData($SURPRISE ,round($info/$size*100, 1))
 Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.
exit

EndSwitch
WEnd

Opublikowano

Tak jak podał sopel jest ok,zamiast 1 dałem 2 i mam zaokrąglenie do 2 liczb po przecinku a nie do całkowitej .

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...